Machine learning based end-to-end extraction of tables from electronic documents

ABSTRACT

In some embodiments, a method includes identifying a set of word bounding boxes in a first electronic document, and identifying locations of horizontal white space between two adjacent rows from a set of rows in a table. The method includes determining, using a Natural Language Processing algorithm, an entity name from a set of entity names for each table cell from a set of table cells in the table. The method includes determining, using a machine learning algorithm a class from a set of classes for each row from the set of rows. The method includes extracting a set of table cell values associated with the set of table cells, and generating a second electronic document including the set of table cell values arranged in the set of rows and the set of columns such that the set of words in the table are computer-readable in the second electronic document.

CROSS-REFERENCE TO RELATED APPLICATION

This application is a continuation of U.S. patent application Ser. No. 16/781,195, titled “Machine Learning Based End-to-End Extraction of Tables From Electronic Documents,” filed Feb. 4, 2020, the disclosure of which is hereby incorporated by reference in its entirety.

FIELD OF THE DISCLOSURE

This disclosure relates to electronic document review and conversion, and more specifically, to machine learning based models for identifying and extracting tables associated with an electronic document.

BACKGROUND

Scanned documents and other image-based documents are often degraded with artifacts such as blurring and fading. Using Optical Character Recognition (OCR) to convert such image- based documents into documents with computer-readable characters is challenging, especially when these documents include tables. Thus, a need exists to improve the accuracy when identifying and extracting tables from such image-based documents.

BRIEF DESCRIPTION OF THE FIGURES

FIG. 1 shows a block diagram illustrating a table identification and extraction system, according to some embodiments.

FIGS. 2A-2B show examples of projection-based white space identification of an example electronic document, according to some embodiments.

FIG. 3 shows an example of a class table with associations between the set of rows in an example electronic document and its corresponding class from a set of classes, according to some embodiments.

FIG. 4 shows an example of projection-based white space identification of an example electronic document, according to some embodiments.

FIG. 5 shows an example electronic document generated by the table identification and extraction system, according to some embodiments.

FIG. 6 shows an example electronic document having a table spanning across multiple pages, according to some embodiments.

FIG. 7 shows a flow chart illustrating a table identification and extraction process using a machine learning algorithm, according to some embodiments.

SUMMARY

In some embodiments, a method includes identifying a set of word bounding boxes in a first electronic document. Each word bounding box from the set of word bounding boxes is associated with a word from a set of words in the first electronic document. The first electronic document includes a table having a set of table cells positioned in a set of rows and a set of columns. The method further includes identifying, based on coordinates of the set of word bounding boxes, locations of horizontal white space between two adjacent rows from the set of rows. The method includes determining, using a Natural Language Processing algorithm, an entity name from a set of entity names for each table cell from the set of table cells. The method includes determining, using a machine learning algorithm and based on (1) the locations of horizontal white space and (2) the plurality of entity names, a class from a set of classes for each row from the set of rows in the table. The method includes extracting a set of table cell values associated with the set of table cells based on, for each row from the set of rows, the class from the set of classes for that row. The method includes generating a second electronic document including the set of table cell values arranged in the set of rows and the set of columns and based on (1) the locations of horizontal white space, (2) locations of vertical white space, such that the set of words in the table are computer-readable in the second electronic document.

DETAILED DESCRIPTION

Knowledge workers spend significant amounts of time reviewing electronic documents to locate information/data of interest. For example, when reviewing a contract (e.g., in a scanned electronic form or an image-based document form), a knowledge worker may manually search for one or more data elements of interest, such as “Start Date” or “Rent Amount,” or for the presence or absence of contractual clauses of interest, such as “Termination Options.” Known approaches for partially automating electronic document review processes typically involve considerable effort on the part of the knowledge worker, who provides annotations for large volumes of training data as part of model generation. Such known approaches generally involve the use of specialized tools, and the training of the associated models is often performed outside the regular workflow. As such, setting up and maintaining such systems can be prohibitively resource-intensive and time consuming. Moreover, the computer-based extraction of data (e.g., numeric, text, tables, etc.) from electronic documents can be inefficient due to errors that are commonly introduced into electronic documents as a result of optical character recognition (OCR) processing, automated language translation and/or automated spell checking of the electronic documents. In addition, for an electronic document including tables, extracting data contained within a table together with the layout of the data in the table can be challenging.

Table identification and extraction systems and methods of the present disclosure address the foregoing issues by identifying, extracting, and reproducing data and tables from scanned documents and other image-based documents (e.g., pictures, invoices, financial statements, purchase orders, and/or the like) with a higher speed, improved quality, increased accuracy and/or improved efficiency. Embodiments described here can identify, extract, and reproduce tables that span multiple pages in an electronic document, and multiple tables in an electronic document. Such embodiments allow relatively fast conversion of a large number of image-based documents containing a large number of tables (such as invoices, bank statements, purchase orders, and/or the like) into documents with computer-readable characters.

In some embodiments, a method includes identifying a set of word bounding boxes in a first electronic document. Each word bounding box from the set of word bounding boxes is associated with a word from a set of words in the first electronic document. The first electronic document includes a table having a set of table cells positioned in a set of rows and a set of columns. The method further includes identifying, based on coordinates of the set of word bounding boxes, locations of horizontal white space between two adjacent rows from the set of rows. The method includes determining, using a Natural Language Processing algorithm, an entity name from a set of entity names for each table cell from the set of table cells. The method includes determining, using a machine learning algorithm and based on (1) the locations of horizontal white space and (2) the plurality of entity names, a class from a set of classes for each row from the set of rows in the table. The method includes extracting a set of table cell values associated with the set of table cells based on, for each row from the set of rows, the class from the set of classes for that row. The method includes generating a second electronic document including the set of table cell values arranged in the set of rows and the set of columns and based on (1) the locations of horizontal white space, (2) locations of vertical white space, such that the set of words in the table are computer-readable in the second electronic document.

As used herein, the singular forms “a,” “an” and “the” include plural referents unless the context clearly dictates otherwise. Thus, for example, the term “an electronic document” is intended to mean a single electronic document or multiple electronic documents.

FIG. 1 shows a block diagram illustrating a table identification and extraction system, according to some embodiments. In some embodiments, the table identification and extraction system 100 is configured to identify and extract tables in electronic documents using a machine learning algorithm to reproduce the tables in a table format having computer-recognizable characters. In some embodiments, the electronic document can be a scanned document or an image-based document such as pictures, invoices, financial statements, picture orders, and/or the like.) In some embodiments, the electronic document can include a table or a plurality of tables. The table identification and extraction system 100 can provide end-to-end capabilities from receiving a scanned document or an image-based document having tables to generate an electronic document with the tables having computer-recognizable characters.

The table identification and extraction system 100 can include a processor 110 and a memory 121 operatively coupled to the processor 110. The table identification and extraction system 100 can be a compute device (or multiple compute devices) having processing capabilities. In some instances, the table identification and extraction system 100 can be any combination of hardware-based module(s) (e.g., a field-programmable gate array (FPGA), an application specific integrated circuit (ASIC), a digital signal processor (DSP)) and/or software-based module(s) (computer code stored in memory 121 and/or executed at the processor 110). In some instances, the table identification and extraction system 100 can be a server such as, for example, a web server, an application server, a proxy server, a telnet server, a file transfer protocol (FTP) server, a mail server, a list server, a collaboration server and/or the like. In other instances, the table identification and extraction system 100 can be a personal computing device such as a desktop computer, a laptop computer, a personal digital assistant (PDA), a standard mobile telephone, a tablet personal computer (PC), and/or so forth. In some instances, the table identification and extraction system 100 can communicate with other servers or client devices (not shown) via a network (not shown) (e.g., the Internet, an intranet, a local area network (LAN), a virtual private network (VPN), a wireless LAN (WLAN), a wired network, a wireless network and/or the like).

The memory 121 can be, for example, a random-access memory (RAM) (e.g., a dynamic RAM, a static RAM), a flash memory, a removable memory, a hard drive, a database and/or so forth. In some implementations, the memory 121 can include (or store), for example, a database, process, application, virtual machine, and/or other software modules (stored and/or executing in hardware) and/or hardware modules configured to execute a table identification and extraction process as described with regards to FIG. 7 (discussed below). In such implementations, instructions for executing the table identification and extraction process and/or the associated methods can be stored within the memory 121 and executed at the processor 110. In some implementations, the memory 121 can store the machine learning (ML) algorithms 123, the Natural Language Processing (NLP) algorithm(s) 127, the table identification program 124, the table extraction program 125, and the Optical Character Recognition (OCR) 126.

The processor 110 can be configured to, for example, write data into and read data from the memory 121, and execute the instructions stored within the memory 121. The processor 110 can also be configured to execute and/or control, for example, the operations of other components of the table identification and extraction system 100 (such as a network interface card, other peripheral processing components (not shown)). In some implementations, based on the instructions stored within the memory 121, the processor 110 can be configured to execute the table identification and extraction process described with respect to FIG. 7 .

In use, the table identification and extraction system 100 can receive a first electronic document (e.g., a scanned document, an image-based document such as a picture, an invoice, a financial statement, a purchase order, and/or the like). The first electronic document can include a table having a set of alphanumeric characters in a set of table cells positioned in a set of rows and a set of columns. In some implementations, the first electronic document can include other data (e.g., texts and/or pictures) that are not arranged in a table format. The table identification and extraction system 100 can use the OCR 126 (or an OCR program external to the table identification and extraction system 100) to convert the first electronic document to a second electronic document having computer-recognizable characters. The OCR 126 (or an OCR program external to the table identification and extraction system 100) can detect and localize coordinates of a set of character bounding boxes. Each character bounding box from the set of character bounding boxes can contain, for example, an alphanumeric character from the set of alphanumeric characters from the first electronic document. In some implementations, the coordinates of each character bounding box includes a horizontal position (an x-axis value) and/or a vertical position (a y-axis value) of each corner of the four corners of the character bounding box. In other implementations, the coordinates of each character bounding box can include (1) a horizontal position (an x-axis value) and/or a vertical position (a y-axis value) of the center of each character bounding box and (2) the size (height and/or width) of each character bounding box.

The table identification program 124 can identify, based on the coordinates of the set of character bounding boxes and using an algorithm, coordinates of a set of word bounding boxes. The algorithm can be stored in the memory 121. Each word bounding box from the set of word bounding boxes contains a word from a set of words in the first electronic document. In some implementations, the coordinates of each word bounding box includes a horizontal position (an x-axis value) and/or a vertical position (a y-axis value) of each corner of the four corners of the word bounding box. In other implementations, the coordinates of each word bounding box includes (1) a horizontal position (an x-axis value) and/or a vertical position (a y-axis value) of the center of each word bounding box and (2) the size (height and/or width) of each word bounding box. In some implementations, the algorithm can be a character grouping algorithm, for example, a Distance Metric algorithm (e.g., customization-based), and can be a supervised or unsupervised algorithm. The character grouping algorithm is based on spacing between characters, lower or upper cases of characters, small or large cases of characters, and average spacing on a page. The Distance Metric algorithm, for example, uses a distance function, which provides a relationship metric between the set of character bounding boxes from the second electronic document. In some implementations, for example, a capital case letter of the alphanumeric character can have a greater size of its character bounding box than that of a lower case letter of the alphanumeric character. Thus, the distance between a capital case letter and a lower case letter and the distance between two lower case letters are treated differently using the algorithm.

In some implementations, the table identification program 124 can identify, based on coordinates of the set of word bounding boxes, locations of horizontal white space between two adjacent rows from the set of rows. Specifically, based on the coordinates of the set of word bounding boxes (e.g., a horizontal position (an x-axis value) and/or a vertical position (a y-axis value) of each corner of the four corners of each word bounding box), the table identification program 124 can identify and project (or predict) the set of rows that have word(s)-filled pixels, as well as the horizontal white space (or horizontal gaps) between two adjacent rows that do not have the word(s)-filled pixels. Stated similarly, the portion of the horizontal position of the second electronic document that does not have projected pixels from the word bounding boxes can be considered as white space (or gaps). In some implementations, the table identification program 124 can record the coordinates of the start and the end of horizontal white space between two adjacent rows from the set of rows.

FIGS. 2A-2B show an example of projection-based white space identification of an example electronic document, according to some embodiments. The electronic document 201 can be an image-based document that includes an invoice. The electronic document 201 includes a first section 202, a second section 203, and a third section 204, in which each section can be a separate table having a set of rows and a set of columns. In some instances, the electronic document can be a single table having a set of rows and a set of columns. The OCR 126 of the table identification and extraction system 100 in FIG. 1 (or an OCR program external to the table identification and extraction system 100) can convert the electronic document 201 (i.e., the first electronic document) to a second electronic document (not shown) having computer-recognizable characters. The OCR 126 (or an OCR program external to the table identification and extraction system 100) can detect and localize coordinates of a set of character bounding boxes. The table identification program 124 of the table identification and extraction system 100 in FIG. 1 can identify, based on the coordinates of the set of character bounding boxes and using the character grouping algorithm, coordinates of a set of word bounding boxes 261 in the second electronic document 251 . The table identification program 124 can define a horizontal dimension 252 (or an x-axis) and a vertical dimension 253 (or a y-axis) of the second electronic document 251. In some implementations, the coordinates of each word bounding box 261 includes a horizontal position (an x-axis value) and/or a vertical position (a y-axis value) of each corner of the four corners of the word bounding box 261. In other implementations, the coordinates of each word bounding box 261 includes (1) a horizontal position (an x-axis value) and/or a vertical position (a y-axis value) of the center of each word bounding box and (2) the size (height and/or width) of each word bounding box. The table identification program 124 can identify, based on coordinates of the set of word bounding boxes 261, locations of horizontal white space between two adjacent rows from the set of rows. For example, the solid lines, for example, 254, 256, 258, and 260 in FIG. 2B, indicate the start of a row (e.g., upper bound) of word bounding boxes. The dotted lines, for example, 255, 257, and 259 in FIG. 2B, indicate the end of a row (e.g., lower bound) of word bounding boxes. The table identification program 124 can identify the dotted lines (e.g., 255, 257, and 259) as the start of the horizontal white space (or horizontal gaps) and the following solid lines (e.g., 256, 258, and 260, respectively) as the end of that horizontal white space (or horizontal gaps).

Returning to FIG. 1 , the table identification program 124 can determine, for each word bounding box from the set of word bounding boxes and using a natural language processing algorithm, an entity name from a set of entity names. The natural language processing algorithm can be stored in the memory 121. The natural language processing algorithm can be, for example, the named-entity recognition algorithm. The table identification program 124 can determine an entity name (or an entity category) for each word bounding box based on its meaning of the word contained in each word bounding box. The set of entity names include, but are not limited to, Cardinal, Date, Person, Organization, Physical Address, Money, Number, Picture, Web Address, Email, Photo Number, NoEntity, and/or the like. If a word bounding box has text that does not match any known entities, the row can be labeled as “NOENTITY”. The table identification program 124 can determine, based on the entity name for each word bounding box, a sequence of entities for each row of the set of rows in the table. The table identification program 124 can identify the locations of each row of the set of rows based on the locations of horizontal white space. For example, for a row that includes three word bounding boxes, the table identification program 124 can determine, based on the natural language processing algorithm, an entity name for each word bounding boxes to be Cardinal, Date, and Person, respectively. Thus, the table identification program 124 can determine the sequence of entities for this row to be Cardinal_Date_Person.

In some implementations, the table identification program 124 can determine, using a machine learning algorithm and based on (1) the locations of horizontal white space and (2) the sequence of entities, a class (or a label, or a classifier) from a set of classes for each row from the set of rows in the table, and/or (3) the sequence of rows from top to bottom of each page of the entire document. The table identification program 124 can store, in memory 121, a class table of the associations between each row from the set of rows and its class. The machine learning algorithm can be stored in the memory 121. In some implementations, the machine learning algorithm can be a trained model using training data. For example, the machine learning algorithm can be a Conditional Random Field (CRF) Machine Learning algorithm based on a probabilistic graphical model. In some implementations, the machine learning algorithm includes a set of weight values indicating probabilities of transition from one class from the set of classes to another class from the set of classes. For example, the trained Conditional Random Field (CRF) Machine Learning model includes two types of parameters that can be learned—namely transition probabilities and emission probabilities. These learned parameters can be used to predict the class for each row of a new table in an electronic document. The class having the highest predicted or inferred (using the trained class) probability value (or weight value) can be the predicted class for that row.

The table identification program 124 can use the machine learning algorithm to predict a class for each row based on the natural language meaning of the entity name of each word bounding box, a number of each entity in the sequence of entities for each row, the previous row's predicted class, the occurrence of predetermined keywords in the text of the word bounding boxes. In some implementations, the table identification program 124 can predict the class for each row based on additional information including the position of each entity name in the sequence of entities, the relationship of each entity name in the sequence of entities, and the context of the set of sequences of entities. The set of classes include, but not limited to, “Header”, “Row”, “Partial Row”, “Table End”, “Miscellaneous”, and/or the like. In some implementations, the “Header” class indicates the starting row (or the header row) of the table (e.g., row 291 in FIGS. 2A-2B). The “Row” class indicates a row that spans across multiple columns (e.g., rows 292 and 294 in FIGS. 2A-2B). The “Partial Row” class indicates a partial row that does not span multiple columns (e.g., rows 293 and 295 in FIGS. 2A-2B). In other words, column (or columns) belonging to a specific row overflowing onto the next line can be a partial-row. In some implementations, any “Partial-Row” is associated with a “Row” all the time. The “Miscellaneous” class indicate rows that are outside the table (e.g., sections 202 and 203 in FIG. 2A) and/or rows between multiple tables in the electronic document. In some implementations, the table identification program 124 can identify the table that starts with a row having a Header class, includes a set of rows having Row classes and/or Partial Row classes, and ends with a row having a Table End class.

FIG. 3 shows an example of a class table with associations between the set of rows in an example electronic document and its corresponding class from a set of classes, according to some embodiments. The class table 300 includes an index column 305 indicating an identifier of each row from the set of rows in an example electronic document (e.g., the example electronic document in FIG. 2A). The class table 300 includes a class column 306 indicating the set of classes that the table identification program 124 determines for each row from the set of rows in the table using the machine learning algorithm. The class table 300 includes an entity sequence column 307, indicating the sequence of entities that the table identification program 124 determines for each row from the set of rows in the table using the natural language processing algorithm. The class table 300 includes a height column 308 indicating the height of each row from the set of rows and a center column 309 indicating the coordinates of the center of each row from the set of rows. The class table 300 for the example electronic document (e.g., the example electronic document in FIG. 2A) can include a first section 302 corresponding to the rows (202 and 203 in FIG. 2A) shown before the table (204 in FIG. 2A), a second section 303 corresponding to the table (204 in FIG. 2A), and a third section 304 corresponding to the rows shown after the table (204 in FIG. 2A). The class “I-HEADER” (or “Header”) 311 indicates the starting row (or the header row) of the table (e.g., row 291 in FIGS. 2A-2B). The class “I-PROW” 312 (or “Partial Row”) indicates a partial row that does not across multiple columns (e.g., rows 293 and 295 in FIGS. 2A-2B). The class “I-ROW” 313 (or “Row”) indicates a row that spans multiple columns (e.g., rows 292 and 294 in FIGS. 2A-2B). The class “I-MISC” 314 (or “Miscellaneous”) indicates rows that are outside the table (e.g., sections 202 and 203 in FIG. 2A) and/or rows between multiple tables in the electronic document.

Returning to FIG. 1 , the table extraction program 125 can identify, based on coordinates of the set of word bounding boxes and the set of classes for the set of rows, locations of vertical white space between two adjacent columns from the set of columns. Specifically, based on the coordinates of the set of word bounding boxes (e.g., a horizontal position (a x-axis value) and/or a vertical position (a y-axis value) of each corner of the four corners of each word bounding box), the table extraction program 125 can identify and project (or predict) the set of columns that have word(s)-filled pixels, as well as the vertical white space (or vertical gaps) between two adjacent columns that do not have the word(s)-filled pixels. Stated similarly, the portion of the vertical dimension of the second electronic document that does not have projected pixels from the word bounding boxes can be considered as white space (or gaps). In some implementations, the table identification program 124 can record the coordinates of the start and the end of vertical white space between two adjacent columns from the set of columns. In some implementations, the table identification program 124 can run the projection of vertical white space based on the coordinates of each row from the set of rows (e.g., the height 308 and the center 309 of each row from the class table 300 in FIG. 3 ). In some implementations, the table identification program 124 can run the projection of vertical white space for a subset of rows that have the classes of “Header” “Row”, and/or “Table End”, and not for the remaining rows with the classes of “Partial Row” or “Miscellaneous.” In such implementations, the remaining rows from the set of rows are different from the subset of rows from the set of rows.

FIG. 4 shows an example of projection-based white space identification of an example electronic document, according to some embodiments. The solid lines 402 indicate the start of a column of word bounding boxes. The dotted lines 401 indicate the end of a column of word bounding boxes. The table extraction program 125 can identify the dotted lines 401 as the start of the vertical white space (or vertical gaps) and the following solid lines 402 as the end of that vertical white space (or vertical gaps).

Returning to FIG. 1 , as described herein, the table identification program 124 can identify the horizontal white space between two adjacent rows in a table and determine a class for each row of the set of the rows in the table. The table extraction program 125 can identify the vertical white space between two adjacent columns in the table. The table identification and extraction system 100 can determine the positions of the rows and the columns of the table based on the horizontal white space and the vertical white space. In some implementations, the table extraction program 125 can extract a set of table cell values (i.e., the alphanumeric characters or words in the set of word bounding boxes) associated with the set of table cells based on the class from the set of classes for each row from the set of rows in the table. In some implementations, the table extraction program 125 can extract first the table cell values for the row that have the classes of “Header” “Row”, and/or “Table End”, and not for the rows with the class of “Partial Row” or “Miscellaneous.” The table extraction program 125 can then merge the table cell values for the rows with the class of “Partial Row” with the table cell values for the subset of rows. The table extraction program 125 can then generate a third electronic document including the set of table cell values arranged in the set of rows and the set of columns and based on (1) the locations of horizontal white space, (2) locations of vertical white space. The table extraction program 125 can generate the third electronic document in a format of Comma-Separated Values (CSV), Excel, or JavaScript Object Notation (JSON), and store the third electronic document in the memory 121.

FIG. 5 shows an example electronic document generated by the table identification and extraction system, according to some embodiments. Based on the horizontal white space, the vertical white space, and the set of table cell value for each table cell of the table, the table extraction program 125 can generate the third electronic document 500, that converts the texts and tables from the first electronic document (e.g., the electronic document 201 in FIG. 2A) into texts and tables that can be recognized, read, edited, and analyzed using a computer. The third electronic document 500 includes the computer-readable words arranged in a set of rows and a set of columns in a table format that allows convenient viewing, editing, and analyzing by compute devices. In addition, the table identification and extraction system 100 allows relatively fast conversion of a large number of image-based documents containing a large number of tables (such as invoices, bank statements, purchase orders, and/or the like) into documents with computer-readable characters.

FIG. 6 shows an example electronic document having a table spanning across multiple pages, according to some embodiments. The electronic document can include a table 600 that spans multiples pages (e.g., first page 601 and second page 602) of the electronic document. The table identification and extraction system 100 can generate a second electronic document 610 by appending a vertical coordinate of the second page 602 with a vertical coordinate of the first page 601. The second electronic document 610 has one page including the set of words from the first page 601 and the second page 602. The table identification and extraction system 100 can treat the second electronic document 610 as an electronic document having one table, and identify and extract the table in the second electronic document 610 using the table identification and extraction process described herein in FIG. 7 . For example, the table identification and extraction system 100 can identify a set of word bounding boxes in the second electronic document 610 and identify, based on coordinates of the set of word bounding boxes, locations of horizontal white space between two adjacent rows from the set of rows. The table identification and extraction system 100 can determine, using a Natural Language Processing algorithm, an entity name from a set of entity names for each table cell from the set of table cells in the table. The table identification and extraction system 100 can determine, using a machine learning algorithm and based on (1) the locations of horizontal white space and (2) the set of entity names, a class from a set of classes 620 for each row from the set of rows in the second electronic document 610, and/or (3) the sequence of rows from top to bottom of each page of the entire document. The table identification and extraction system 100 can identify, based on coordinates of the set of word bounding boxes and the set of classes for the set of rows, locations of vertical white space between two adjacent columns from the set of columns. The table identification and extraction system 100 can extract a set of table cell values associated with the set of table cells based on, for each row from the set of rows, the class from the set of classes for that row. The table identification and extraction system 100 can generate a third electronic document including the set of table cell values arranged in the set of rows and the set of columns and based on (1) the locations of horizontal white space, (2) locations of vertical white space, such that the set of words in the table of the second electronic document 610 are computer-readable in the third electronic document.

FIG. 7 shows a flow chart illustrating a table identification and extraction process using a machine learning algorithm, according to some embodiments. This table identification and extraction process 700 can be implemented at a processor and/or a memory (e.g., processor 110 or memory 121 as discussed with respect to FIG. 1 of a table identification and extraction system 100).

At 701, the table identification and extraction process 700 includes identifying a set of word bounding boxes in a first electronic document. The first electronic document can include a scanned document, an image-based document such as a picture, an invoice, a financial statement, a purchase order, and/or the like. The first electronic document can include a table having a set of alphanumeric characters in a set of table cells positioned in a set of rows and a set of columns. The table identification and extraction system can use an Optical Character Recognition (OCR) to recognize the alphanumeric characters and localize coordinates of a set of character bounding boxes. Each character bounding box from the set of character bounding boxes contains an alphanumeric character from the set of alphanumeric characters from the first electronic document. Based on the coordinates of the set of character bounding boxes and using an algorithm, the table identification and extraction process 700 includes identifying a set of word bounding boxes in a first electronic document. Each word bounding box from the set of word bounding boxes contains a word from a set of words in the first electronic document. In some implementations, the coordinates of each word bounding box includes a horizontal position (an x-axis value) and/or a vertical position (a y-axis value) of each corner of the four corners of the word bounding box. In other implementations, the coordinates of each word bounding box includes (1) a horizontal position (an x-axis value) and/or a vertical position (a y-axis value) of the center of each word bounding box and (2) the size (height and/or width) of each word bounding box. In some implementations, this algorithm can be a character grouping algorithm, for example, a Distance Metric algorithm, and can be a supervised or unsupervised algorithm. The character grouping algorithm is based on spacing between characters, lower or upper cases of characters, small or large cases of characters, and average spacing on a page. The Distance Metric algorithm, for example, uses a distance function that provides a relationship metric between the set of character bounding boxes from the second electronic document.

At 703, the table identification and extraction process 700 includes identifying (projecting, or predicting), based on coordinates of the set of word bounding boxes, locations of horizontal white space between two adjacent rows from the set of rows. Specifically, based on the coordinates of the set of word bounding boxes (e.g., a horizontal position (a x-axis value) and/or a vertical position (a y-axis value) of each corner of the four corners of each word bounding box), the table identification and extraction process 700 includes identifying, projecting, or predicting locations of horizontal white space between two adjacent rows from the set of rows. In other words, the portion of the horizontal dimension of the first electronic document that does not have projected pixels from the word bounding boxes can be considered as white space (or gaps).

At 705, the table identification and extraction process 700 includes determining, using a Natural Language Processing algorithm, an entity name from a set of entity names for each table cell in each row from the set of table cells. The natural language processing algorithm can be, for example, the named-entity recognition algorithm. The table identification and extraction system determines an entity name for each word bounding box based on its meaning of the word contained in each word bounding box. The set of entity names include, but are not limited to, Cardinal, Date, Person, Organization, Physical Address, Money, Number, Picture, Web Address, Email, Photo Number, NoEntity, and/or the like. If a word bounding box has text that does not match any known entities, the row can be labeled as “NOENTITY”. The table identification and extraction system determines, based on the entity name for each word bounding box, a sequence of entities for each row of the set of rows in the table. For example, for a row that includes three word bounding boxes, the table identification and extraction system determines, based on the natural language processing algorithm, an entity name for each word bounding box to be Cardinal, Date, and Person, respectively. Thus, the table identification and extraction system determines the sequence of entities for this row to be Cardinal_Date_Person.

At 707, the table identification and extraction process 700 includes determining, using a machine learning algorithm and based on (1) the locations of horizontal white space and (2) the plurality of entity names, a class from a set of classes for each row from the set of rows in the table, and/or (3) the sequence of rows from top to bottom of each page of the entire document. In some implementations, the machine learning algorithm can be a trained model using training data. For example, the machine learning algorithm can be a Conditional Random Field (CRF) Machine Learning algorithm based on a probabilistic graphical model. The table identification and extraction system uses the machine learning algorithm to predict a class for each row based on the natural language meaning of the entity of each word bounding box, a number of each entity in the sequence of entities for each row, the previous row's predicted class, the occurrence of predetermined keywords in the text of the word bounding boxes. In some implementations, the table identification program 124 can predict the class for each row based on additional information including the position of each entity in the sequence of entities, the relationship of each entity in the sequence of entities, and the context of the set of sequences of entities. The set of classes include, but not limited to, “Header”, “Row”, “Partial Row”, “Table End”, “Miscellaneous”, and/or the like. In some implementations, the “Header” class indicates the starting row (or the header row) of the table. The “Row” class indicates a row that spans multiple columns. The “Partial Row” class indicates a partial row that does not span multiple. The “Miscellaneous” class indicates rows that are outside the table and/or rows between multiple tables in the electronic document. In some implementations, the table identification and extraction system identifies the table that starts with a row having a Header class, includes a set of rows having Row classes and/or Partial Row classes, and ends with a row having a Table End class.

In some implementations, the table identification and extraction process 700 includes identifying, based on coordinates of the set of word bounding boxes and the set of classes for the set of rows, locations of vertical white space between two adjacent columns from the set of columns. Specifically, based on the coordinates of the set of word bounding boxes (e.g., a horizontal position (a x-axis value) and/or a vertical position (a y-axis value) of each corner of the four corners of each word bounding box), the table identification and extraction system identifies and projects (or predicts) the set of columns that have word(s)-filled pixels, as well as the vertical white space (or vertical gaps) between two adjacent columns that do not have the word(s)-filled pixels. In some implementations, the table identification and extraction system runs the projection of vertical white space based on the coordinates of each row from the set of rows (e.g., the height 308 and the center 309 of each row from the class table 300 in FIG. 3 ). In some implementations, the table identification program 124 can run the projection of vertical white space for a subset of rows that have the classes of “Header” “Row”, and/or “Table End”, and not for the remaining rows with the classes of “Partial Row” or “Miscellaneous.”

At 709, the table identification and extraction process 700 includes extracting a set of table cell values associated with the set of table cells based on, for each row from the set of rows, the class from the set of classes for that row. In some implementations, the table identification and extraction process 700 includes first extracting the table cell values for the subset of rows that have the classes of “Header” “Row”, and/or “Table End”, and not for the remaining rows with the class of “Partial Row” or “Miscellaneous.” The table identification and extraction then merges the table cell values for the remaining rows with the class of “Partial Row” with the table cell values for the subset of rows.

At 711, the table identification and extraction process 700 includes generating a second electronic document including the set of table cell values arranged in the set of rows and the set of columns and based on (1) the locations of horizontal white space, (2) locations of vertical white space, such that the set of words in the table are computer-readable in the second electronic document. The second electronic document can be in a format of Comma-Separated Values (CSV), Excel, or JavaScript Object Notation (JSON). The second electronic document includes the computer-readable words arranged in a set of rows and a set of columns in a table format that allows convenient viewing, editing, and analyzing by compute devices. In addition, the second electronic document allows relatively fast conversion of a large number of image-based documents containing a large number of tables (such as invoices, bank statements, purchase orders, and/or the like) into documents with computer-readable characters.

Although various embodiments have been described as having particular features and/or combinations of components, other embodiments are possible having a combination of any features and/or components from any of embodiments as discussed above.

Some embodiments described herein relate to a computer storage product with a non-transitory computer-readable medium (also can be referred to as a non-transitory processor- readable medium) having instructions or computer code thereon for performing various computer-implemented operations. The computer-readable medium (or processor-readable medium) is non-transitory in the sense that it does not include transitory propagating signals per se (e.g., a propagating electromagnetic wave carrying information on a transmission medium such as space or a cable). The media and computer code (also can be referred to as code) may be those designed and constructed for the specific purpose or purposes. Examples of non-transitory computer- readable media include, but are not limited to, magnetic storage media such as hard disks, floppy disks, and magnetic tape; optical storage media such as Compact Disc/Digital Video Discs (CD/DVDs), Compact Disc-Read Only Memories (CD-ROMs), and holographic devices; magneto-optical storage media such as optical disks; carrier wave signal processing modules; and hardware devices that are specially configured to store and execute program code, such as Application-Specific Integrated Circuits (ASICs), Programmable Logic Devices (PLDs), Read-Only Memory (ROM) and Random-Access Memory (RAM) devices. Other embodiments described herein relate to a computer program product, which can include, for example, the instructions and/or computer code discussed herein.

Some embodiments and/or methods described herein can be performed by software (executed on hardware), hardware, or a combination thereof. Hardware modules may include, for example, a general-purpose processor, a field programmable gate array (FPGA), and/or an application specific integrated circuit (ASIC). Software modules (executed on hardware) can be expressed in a variety of software languages (e.g., computer code), including C, C++, Java™ Ruby, Python, Visual Basic™, and/or other object-oriented, procedural, or other programming language and development tools. Examples of computer code include, but are not limited to, micro-code or micro-instructions, machine instructions, such as produced by a compiler, code used to produce a web service, and files containing higher-level instructions that are executed by a computer using an interpreter. For example, embodiments may be implemented using imperative programming languages (e.g., C, Fortran, etc.), functional programming languages (Haskell, Erlang, etc.), logical programming languages (e.g., Prolog), object-oriented programming languages (e.g., Java, C++, etc.) or other suitable programming languages and/or development tools. Additional examples of computer code include, but are not limited to, control signals, encrypted code, and compressed code. 

What is claimed is:
 1. A processor-readable non-transitory medium storing code representing instructions to be executed by a processor, the code comprising code to cause the processor to: identify a plurality of word bounding boxes in a first electronic document, each word bounding box from the plurality of word bounding boxes associated with a word from a plurality of words in the first electronic document, the first electronic document including a table having a set of table cells positioned in a set of rows and a set of columns; identify, based on a horizontal position and a vertical position of at least two corners of each word bounding box from the plurality of word bounding boxes, locations of horizontal gaps between two adjacent rows from the set of rows; determine, using a machine learning algorithm and based on (1) the locations of horizontal gaps and (2) a plurality of entity names from the table, a class from a set of classes for each row from the set of rows in the table; extract a set of table cell values associated with the set of table cells based on, for each row from the set of rows, the class from the set of classes for that row; and generate a second electronic document including the set of table cell values arranged in the set of rows and the set of columns and based on (1) the locations of horizontal gaps, (2) locations of vertical gaps, such that the plurality of words in the table are computer-readable in the second electronic document.
 2. The processor-readable non-transitory medium of claim 1, the code further comprising code to cause the processor to: receive the first electronic document from an optical character recognition program.
 3. The processor-readable non-transitory medium of claim 1, wherein: the first electronic document includes a first page and a second page; the code further comprising code to cause the processor to generate a third electronic document by appending a vertical coordinate of the second page with a vertical coordinate of the first page, the third electronic document having one page including the plurality of words from the first page and the second page.
 4. The processor-readable non-transitory medium of claim 1, wherein the first electronic document includes a plurality of tables including the table.
 5. The processor-readable non-transitory medium of claim 1, wherein the set of classes includes at least one of Header, Row, Partial Row, or Table End.
 6. The processor-readable non-transitory medium of claim 1, wherein the second electronic document is in a format of Comma-Separated Values (CSV), Excel, or JavaScript Object Notation (JSON).
 7. The processor-readable non-transitory medium of claim 1, wherein: the horizontal gaps includes horizontal gaps between each two adjacent rows from the set of rows.
 8. An apparatus, comprising: a memory; and a processor operatively coupled to the memory, the processor configured to: identify each word bounding box from a plurality of word bounding boxes associated with a word from a plurality of words in a first electronic document, determine, based on locations of the plurality of word bounding boxes, gaps in a horizontal dimension of the first electronic document to identify a plurality of rows of a table included in the first electronic document, each row from the plurality of rows (1) including a set of words from the plurality of words and (2) being divided into a plurality of cells separated by the gaps in the horizontal dimension, determine, using a machine learning algorithm, a class from a set of classes for each row from the plurality of rows in the table based on (1) a sequence of entity names from a plurality of entity names and for each row from the plurality of rows, and (2) a class of a row proceeding that row, extract, for each row from a subset of rows from the plurality of rows and based on the class from the set of classes for that row, a first set of word values associated with a set of words included in that row, generate a second electronic document based on (1) the first set of word values in each row from the subset of rows, (2) the plurality of rows of the table, and (3) the gaps in the horizontal dimension, such that the plurality of words in the table are computer-readable in the second electronic document, the remaining rows from the plurality of rows being different from the subset of rows from the plurality of rows.
 9. The apparatus of claim 8, wherein the processor is configured to receive the first electronic document from an optical character recognition program.
 10. The apparatus of claim 8, wherein: the first electronic document includes a first page and a second page; the processor is configured to generate a third electronic document by appending a vertical coordinate of the second page with a vertical coordinate of the first page, the third electronic document having one page including the plurality of characters from the first page and the second page.
 11. The apparatus of claim 8, wherein the first electronic document includes a plurality of tables including the table.
 12. The apparatus of claim 8, wherein the second electronic document is in a format of Comma-Separated Values (CSV), Excel, or JavaScript Object Notation (JSON).
 13. The apparatus of claim 8, wherein: the set of classes includes at least one of Header, Row, Partial Row, or Table End; each row from the subset of rows has a class of Row; each row from the remaining rows has a class of Partial Row.
 14. The apparatus of claim 8, wherein: the processor is configured to determine, using a Natural Language Processing algorithm, an entity name from the plurality of entity names for each cell from the plurality of cells in each row from the plurality of rows, and the plurality of entity names includes at least one of Date, Person, Location, Organization, Number, Money, Cardinal, or No Entity.
 15. The apparatus of claim 8, wherein the machine learning algorithm includes a set of weight values indicating probabilities of transition from one class from the set of classes to another class from the set of classes.
 16. The apparatus of claim 8, wherein the table spans across multiple pages in the first electronic document.
 17. The apparatus of claim 8, wherein the processor is configured to determine, based on (1) the locations of the plurality of word bounding boxes and (2) the set of classes for the plurality of rows, the gaps in the vertical dimension of the first electronic document.
 18. A method, comprising: identifying, based on locations of a plurality of character bounding boxes in a first electronic document, each word bounding box from a plurality of word bounding boxes associated with a word from a plurality of words in the first electronic document, the first electronic document including a table having a set of table cells positioned in a set of rows; identifying, based on coordinates of the plurality of word bounding boxes, locations of horizontal gaps between two adjacent rows from the set of rows; determining, using a machine learning algorithm, a class from a set of classes for each row from the set of rows in the table based on (1) the locations of horizontal gaps, (2) a sequence of entity names for each row from the set of rows, and (3) a class of a row proceeding to that row; extracting a set of table cell values associated with the set of table cells; and generating a second electronic document including the set of table cell values arranged in the set of rows and based on the locations of horizontal gaps, such that the plurality of words in the table are computer-readable in the second electronic document.
 19. The method of claim 18, wherein: the code to receive includes code to receive the first electronic document from an optical character recognition program and includes a first page, a second page and a plurality of tables including the table.
 20. The method of claim 18, wherein: the set of classes includes at least one of Row, Partial Row, or Table End, and the second electronic document is in a format of Comma-Separated Values (CSV), Excel, or JavaScript Object Notation (JSON). 